﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HyperPin_Database_Editor
{
    public partial class HPWheelSettings : HPSettingsPanel
    {
        static string iniSpeed = "Speed";
        static string iniTextFont = "Text_Font";
        static string iniTextStrokeSize = "Text_Stroke_Size";
        static string iniTextStrokeColor = "Text_Stroke_Color";
        static string iniTextColor1 = "Text_Color1";
        static string iniTextColor2 = "Text_Color2";
        static string iniTextColor3 = "Text_Color3";
        static string iniColorRatio = "Color_Ratio";
        static string iniShadowDistance = "Shadow_Distance";
        static string iniShadowAngle = "Shadow_Angle";
        static string iniShadowColor = "Shadow_Color";
        static string iniShadowAlpha = "Shadow_Alpha";
        static string iniShadowBlur = "Shadow_Blur";

        public HPWheelSettings()
        {
            InitializeComponent();
        }

        public override void doLoadSettings()
        {
            comboSpeed.Text = readSetting(iniSpeed, "high");
            comboTextFont.Text = readSetting(iniTextFont, "Style1");
            numericTextStrokeSize.Value = readSettingInt(iniTextStrokeSize, 8);
            pictureStrokeColor.BackColor = readSettingColor(iniTextStrokeColor, Color.Black);
            pictureTextColor1.BackColor = readSettingColor(iniTextColor1, Color.Green);
            pictureTextColor2.BackColor = readSettingColor(iniTextColor2, Color.White);
            pictureTextColor3.BackColor = readSettingColor(iniTextColor3, Color.Blue);
            numericColorRatio.Value = readSettingInt(iniColorRatio, 100);
            numericShadowDistance.Value = readSettingInt(iniShadowDistance, 0);
            numericShadowAngle.Value = readSettingInt(iniShadowAngle, 45);
            pictureShadowColor.BackColor = readSettingColor(iniShadowColor, Color.White);
            numericShadowAlpha.Value = readSettingDecimal(iniShadowAlpha, Decimal.One);
            numericShadowBlur.Value = readSettingInt(iniShadowBlur, 0);
        }

        public override void doSaveSettings()
        {
            writeSetting(iniSpeed, comboSpeed.Text);
            writeSetting(iniTextFont, comboTextFont.Text);
            writeSettingInt(iniTextStrokeSize, (int)numericTextStrokeSize.Value);
            writeSettingColor(iniTextStrokeColor, pictureStrokeColor.BackColor);
            writeSettingColor(iniTextColor1, pictureTextColor1.BackColor);
            writeSettingColor(iniTextColor2, pictureTextColor2.BackColor);
            writeSettingColor(iniTextColor3, pictureTextColor3.BackColor);
            writeSettingInt(iniColorRatio, (int)numericColorRatio.Value);
            writeSettingInt(iniShadowDistance, (int)numericShadowDistance.Value);
            writeSettingInt(iniShadowAngle, (int)numericShadowAngle.Value);
            writeSettingColor(iniShadowColor, pictureShadowColor.BackColor);
            writeSettingDecimal(iniShadowAlpha, numericShadowAlpha.Value);
            writeSettingInt(iniShadowBlur, (int)numericShadowBlur.Value);


        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            DialogResult result = colorDialogChooseColor.ShowDialog();
            if (result == DialogResult.OK)
            {
                pictureStrokeColor.BackColor = colorDialogChooseColor.Color;
            }
        }

        private void pictureTextColor1_Click(object sender, EventArgs e)
        {
            DialogResult result = colorDialogChooseColor.ShowDialog();
            if (result == DialogResult.OK)
            {
                pictureTextColor1.BackColor = colorDialogChooseColor.Color;
            }

        }

        private void pictureTextColor2_Click(object sender, EventArgs e)
        {
            DialogResult result = colorDialogChooseColor.ShowDialog();
            if (result == DialogResult.OK)
            {
                pictureTextColor2.BackColor = colorDialogChooseColor.Color;
            }

        }

        private void pictureTextColor3_Click(object sender, EventArgs e)
        {
            DialogResult result = colorDialogChooseColor.ShowDialog();
            if (result == DialogResult.OK)
            {
                pictureTextColor3.BackColor = colorDialogChooseColor.Color;
            }

        }

        private void pictureShadowColor_Click(object sender, EventArgs e)
        {
            DialogResult result = colorDialogChooseColor.ShowDialog();
            if (result == DialogResult.OK)
            {
                pictureShadowColor.BackColor = colorDialogChooseColor.Color;
            }
        }

    }
}
